//////////////////////////////////////////////////////////////////////
// IAStage.h
//
// SHEN Fangyang
// me@shenfy.com
//
// Copyright (C) SHEN Fangyang, 2011, All rights reserved.
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
//  Brief Description
//
//	Input-Assembler stage wrapper.
//
//////////////////////////////////////////////////////////////////////
#pragma once
#include <ManagerBase.h>
#include <vector>

namespace grflib
{
	namespace engine
	{
		namespace core
		{
			typedef BYTE* IAInputSignature;

			//IA stage wrapper
			class CIAStage
			{
			public:
				CIAStage(void);
				virtual ~CIAStage(void);

				//select or create IA input layout and set it as current layout
				HRESULT SetInputLayout(std::size_t VSSignature,
					BYTE *pVSByteCode,
					std::size_t VSByteCodeSize,
					const std::vector<D3D10_INPUT_ELEMENT_DESC> &elements);

				void SetVertexBuffers(UINT startSlot, 
					UINT nBuffer, 
					ID3D10Buffer *const *ppVB,
					const UINT *pStrides,
					const UINT *pOffsets);
				
				//simplified for single buffer
				void SetVertexBuffer(UINT startSlot, 
					ID3D10Buffer *pVB, 
					UINT stride, 
					UINT offset);

				void SetIndexBuffer(ID3D10Buffer *pIndexBuffer,
					DXGI_FORMAT format,
					UINT offset);

				void SetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY topology);

				void OnDestroy(void);

			private:
				boost::shared_ptr<ID3D10InputLayout> m_pCurrentLayout;
				_CManagerBase<ID3D10InputLayout, std::size_t/*hash value as key*/> m_layouts;
			};

		} //namespace core
	} //namespace engine
} //namespace grflib